use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct Struct yata::indicators::EldersForceIndex Elders Force Index

///
///  参见[EFI](https://www.investopedia.com/terms/f/force-index.asp)
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct EFI {
    ///1 signal
    /// Signal 1 appears when main value crosses zero line.
    /// When main value crosses zero line upwards, returns full buy signal.
    /// When main value crosses zero line downwards, returns full sell signal.
    ///
    pub signal0: Option<IndicatorActionWrap>,

    ///1 value
    ///Main value
    ///Range in (-inf; +inf)
    pub main: ValueType,
}

/// Configuration Elders Force Index
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct EFIConfig {
    /// ma: M
    /// Main moving average type.
    ///
    /// Default is EMA(13).
    ///
    /// Period range in [2; PeriodType::MAX).
    pub ma: PeriodType,

    /// period2: PeriodType
    /// Price change period. Default is 1.
    ///
    /// Range in [1; PeriodType::MAX).
    pub period2: PeriodType,
    //source: Source
    //Price source type of values. Default is Close.
}

impl Default for EFIConfig {
    fn default() -> Self {
        Self { ma: 13, period2: 1 }
    }
}
